<#-- @ftlvariable name="entity" type="com.xci.platform.auth.entity.MessageEntity" -->
<#include "/_inc/_layout.ftl">
<@header/>
<div class="jxpanel winpanel" data-fit="true">
    <form id="editform" class="jxform" method="post" action="<@spring.url '/auth/message/save'/>">
        <input name="id" value="${entity.id!}" type="hidden">
        <table class="table jxtable-form" style="width: 96%">
            <tr>
                <th class="w-100px">收件人</th>
                <td>
                    <select class="form-control jxselect" multiple
                            name="receiveUserId"
                            data-allow-clear="false"
                            data-validate="{required: [true,'请选择收件人']}">
                        <option value="-1">@所有人</option>
                        <@html.systemUser selectedValue=entity.receiveUserId isMultiple=true/>
                    </select>
                </td>
            </tr>
            <tr>
                <th>标题</th>
                <td>
                    <input class="form-control" name="title" value="${entity.title!}" maxlength="100"
                           data-validate="required: [true,'请输入消息标题']" autocomplete="off"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="padding-left: 50px">
                    <textarea id="messageContent" name="messageContent" data-validate="required: [true,'请输入内容']"></textarea>
                </td>
            </tr>
        </table>
    </form>
    <div class="panel-footer text-right">
        <@html.editPanelFooter/>
    </div>
</div>
<@footer>
    <@html.ueScript/>
    <script>
        function initUEditor() {
            var ops = $.extend({}, jx.auth.simpleUEOptions(), {initialFrameHeight: 300, serverUrl: '<@html.ueditorServerUrl/>'});
            UE.getEditor('messageContent', ops);
        }
        $('#editform').on("beforesubmit", function () {
            var editor = UE.getEditor('messageContent');
            var content = editor.getPlainTxt().trim();
            if (content == '') {
                jx.toastr.error('请输入消息内容');
                editor.focus();
                return false;
            }
            return true;
        });

        jx.auth.bindEditFormSuccess();
        initUEditor();
    </script>
</@footer>